<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 键盘事件；
        document.onkeydown = function (e) {
            // var code = e.keyCode; //ASSCI码 ：废弃 
            var key = e.key;
            console.log(e.shiftKey,key);

            // if(e.shiftKey && key=="C"){
            //     console.log("按下了 shift+ c按键");
            // }

            switch (key) {
                case 'a':
                    if(e.altKey){
                        console.log("按了alt + a键");
                    }
                    break;
                case 'b':
                    if(e.ctrlKey){
                        console.log("按了b+ctrl按键");
                    }
                    break;
                case "C":
                    console.log(e.shiftKey)
                    if(e.shiftKey){
                        console.log("按了c+shift按键");
                    }
                    break;
                default:
                    console.log("按了除了a和b的按键");
                    break;
            }

        }



    </script>
</body>

</html>